<?php
class cmsFile
{
  
  public static function delete($file, $table, $type = null)
  {
    $files = array();
    
    $uploadDir = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . $table . DIRECTORY_SEPARATOR;
    
    if($file['type'] == 1 || $type == 'image')
    {
      $files = glob($uploadDir . $file['name']."_?.".$file['extension']);
    }
    else
    {
      $files[] = $uploadDir . $file['name'].".".$file['extension'];
    }
    
    try
    {
       array_map('unlink', $files);
    } 
    catch (Exception $exc)
    {
      echo $exc->getTraceAsString();
    }
    
  }

}
?>